<style>
#modal-update {
	padding: 20px 25px 25px 0;
}

#modal-update.layui-treeSelect .ztree li a, .ztree li span {
	margin: 0 0 2px 3px !important;
}

.layui-input-block {
	margin-left: 160px;
}

.layui-form-label {
	width: 130px;
}
</style>
<div class="layui-fluid" id="modal-update">
	<form class="layui-form" action="" lay-filter="modal-update-form">
		<div class="layui-form-item">
			<label class="layui-form-label">Work Time：</label>
			<div class="layui-input-block">
				<input type="text" name="workTime" class="layui-input" id="workTime">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label febs-form-item-require">category：</label>
			<div class="layui-input-block">
				<select name="category" lay-verify="required">
					<option value="local">local</option>
					<option value="ftp">ftp</option>
					<option value="sftp">sftp</option>
				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">errorcode：</label>
			<div class="layui-input-block">
				<input type="text" name="errorcode" autocomplete="off" lay-verify="required|number"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">emailGroup：</label>
			<div class="layui-input-block">
				<select name="emailGroup" id="emailGroup-select" lay-verify="required"
					lay-filter="createOptions3">
				</select>
			</div>
		</div>
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">description：</label>
			<div class="layui-input-block">
				<textarea name="description" lay-verify="required"
					class="layui-textarea"></textarea>
			</div>
		</div>
		<div class="layui-form-item febs-hide">
			<button class="layui-btn" lay-submit=""
				lay-filter="update-form-submit" id="submit"></button>
		</div>
	</form>
</div>

<script data-th-inline="javascript">
    layui.use(['febs', 'form', 'formSelects', 'validate', 'treeSelect'], function () {
        var $ = layui.$,
            febs = layui.febs,
            layer = layui.layer,
            formSelects = layui.formSelects,
            treeSelect = layui.treeSelect,
            form = layui.form,
            $view = $('#modal-update'),
            validate = layui.validate,
			modalData;
			febs.createOptions('fdiMetadataGroupDefine', $('#emailGroup-select'), {key1:'id',key2:'groupDescription'});
			var laydate = layui.laydate;
						//执行一个laydate实例
						laydate.render({
							elem : '#workTime' ,//指定元素
							range : true ,
							type : 'time' ,
							value : '09:00:00 - 17:00:00'
						});
			
        form.verify(validate);
        form.render('radio');

        initFormValue();
        function initFormValue() {
			modalData=parent.tableData;

            form.val("modal-update-form", {
				"category": modalData.category,
				"description":modalData.description,
				"emailGroup": modalData.groupDescription,
				"errorcode": modalData.errorcode,
				"workTime":febs.convertToHHMMSS(modalData.worktimeStart)+" - "+febs.convertToHHMMSS(modalData.worktimeEnd)
			});
        }
		
        form.on('submit(update-form-submit)', function (data) {
        	var worktimeEnd , worktimeStart, worktime =
									data.field.workTime;
							if (worktime) {
								worktimeStart = worktime.split('-')[0].trim();
								worktimeEnd = worktime.split('-')[1].trim();
							}
							data.field.emailGroup = document.getElementById("emailGroup-select").value;
							data.field.worktimeStart=worktimeStart;
							data.field.worktimeEnd=worktimeEnd;
        	var d=febs.nativeCopy(modalData,data.field);			
			d.emailGroup=document.getElementById("emailGroup-select").value;
            if (febs.nativeEqual(d, modalData)) {
                febs.alert.warn('Data have no changes！');
                return false;
            }
            febs.post(ctx + 'fdiErrorcodeConfig/update', d, function () {
                layer.closeAll();
                febs.alert.success('Data Modified!');
				$('#febs-table-container').find('#query').click();
            });
            return false;
		});
		
    });
</script>